package com.xuecheng.learning.controller;

import com.xuecheng.api.learning.CourseRecordApi;
import com.xuecheng.api.learning.model.dto.CourseRecordDTO;
import com.xuecheng.learning.common.utils.UAASecurityUtil;
import com.xuecheng.learning.service.CourseRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 选课记录 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
public class CourseRecordController implements CourseRecordApi {

    @Autowired
    private CourseRecordService  courseRecordService;

    @GetMapping("learnedRecords/myCourseRec/{coursePubId}")
    public CourseRecordDTO getRecordByCoursePubId(@PathVariable Long coursePubId) {

        String username = UAASecurityUtil.getUser().getUsername();

        CourseRecordDTO dto = courseRecordService.getRecordByCoursePubId(coursePubId, username);

        return dto;
    }



}
